package com.hrzyit.whistle.cases.ui.adapter

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.hrzyit.whistle.cases.R
import com.hrzyit.whistle.cases.data.bean.CaseIndexUserInfoVo
import kotlinx.android.synthetic.main.item_index_select_dept_user.view.*
import kotlinx.android.synthetic.main.item_select_dept_user.view.*
import me.yokeyword.indexablerv.IndexableAdapter

/**
 * 单位-索引选择器适配器
 * @author YangWei
 * @date 2019/4/20
 */
class IndexUserSelectAdapter(context:Context):IndexableAdapter<CaseIndexUserInfoVo>(){

    private var mInflater: LayoutInflater = LayoutInflater.from(context)


    override fun onCreateTitleViewHolder(parent: ViewGroup?): RecyclerView.ViewHolder {
        val view = mInflater.inflate(R.layout.item_index_transfer_user, parent, false)
        return IndexVH(view)
    }

    override fun onCreateContentViewHolder(parent: ViewGroup?): RecyclerView.ViewHolder {
        val view = mInflater.inflate(R.layout.item_transfer_user, parent, false)
        return ContentVH(view)
    }

    // 绑定行数据
    override fun onBindContentViewHolder(holder: RecyclerView.ViewHolder?, entity: CaseIndexUserInfoVo?) {
        var vh = holder as ContentVH
        vh.mNameTv.text = entity?.name
        vh.itemView.mSelectedCb.isChecked = entity?.isChecked ?: false
        vh.itemView.mSelectedCb.isClickable = false
    }

    // 绑定索引数据
    override fun onBindTitleViewHolder(holder: RecyclerView.ViewHolder?, indexTitle: String?) {
        var vh = holder as IndexVH
        vh.mIndexTv.text = indexTitle
    }

    private  class IndexVH(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var mIndexTv: TextView = itemView.mIndexTv as TextView

    }

    private class ContentVH(itemView: View) : RecyclerView.ViewHolder(itemView) {
         var mNameTv: TextView = itemView.mNameTv as TextView
    }

}